package com.efounder.bz.flow.drive;

import java.util.Map;

import com.efounder.builder.base.data.*;
import com.efounder.flowbuilder.dat.FlowNode;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class NodeTaskDataSet extends EFDataSet implements java.io.Serializable{
	/**
	 *
	 */
	protected Map nInEdges  = null;

	public Map getnInEdges() {
		return nInEdges;
	}
	public void setnInEdges(Map nInEdges) {
		this.nInEdges = nInEdges;
	}

	/**
	 * 
	 * @return String[]
	 */
	public String[] getInEdges() {
		if (nInEdges == null || nInEdges.size() == 0)
			return null;
		String[] edges = new String[nInEdges.size()];
		edges = (String[]) nInEdges.keySet().toArray(edges);
		return edges;
	}

	/**
	 * 
	 * @param edgeID
	 *            String
	 * @return FlowEdge
	 */
	public FlowEdge getInEdge(String edgeID) {
		if (nInEdges == null)
			return null;
		return (FlowEdge) nInEdges.get(edgeID);
	}

	/**
	 * 
	 * @param edgeID String
     */
	public void putInEdge(String edgeID, FlowEdge flowEdge) {
		if (nInEdges == null)
			nInEdges = new java.util.HashMap();
		nInEdges.put(edgeID, flowEdge);
	}

	protected Map nOutEdges = null;

	public Map getnOutEdges() {
		return nOutEdges;
	}

	public void setnOutEdges(Map nOutEdges) {
		this.nOutEdges = nOutEdges;
	}

	/**
	 * 
	 * @return String[]
	 */
	public String[] getOutEdges() {
		if (nOutEdges == null || nOutEdges.size() == 0)
			return null;
		String[] edges = new String[nOutEdges.size()];
		edges = (String[]) nOutEdges.keySet().toArray(edges);
		return edges;
	}

	public FlowEdge getOutEdge(String edgeID) {
		if (nOutEdges == null)
			return null;
		return (FlowEdge) nOutEdges.get(edgeID);
	}

	/**
	 * 
	 * @param edgeID String
	 * @param flowEdge String
	 */
	public void putOutEdge(String edgeID, FlowEdge flowEdge) {
		if (nOutEdges == null)
			nOutEdges = new java.util.HashMap();
		nOutEdges.put(edgeID, flowEdge);
	}

	protected Map nOutManEdges = null;

	public Map getnOutManEdges() {
		return nOutManEdges;
	}

	public void setnOutManEdges(Map nOutManEdges) {
		this.nOutManEdges = nOutManEdges;
	}

	/**
	 * 
	 * @return String[]
	 */
	public String[] getOutManEdges() {
		if (nOutManEdges == null || nOutManEdges.size() == 0)
			return null;
		String[] edges = new String[nOutManEdges.size()];
		edges = (String[]) nOutManEdges.keySet().toArray(edges);
		java.util.List list = new java.util.ArrayList();
		for (int i = 0; i < edges.length; i++)
			list.add(edges[i]);
		java.util.Collections.sort(list);
		for (int i = 0; i < edges.length; i++)
			edges[i] = (String) list.get(i);

		return edges;
	}

	public FlowEdge getOutManEdge(String edgeID) {
		if (nOutManEdges == null)
			return null;
		return (FlowEdge) nOutManEdges.get(edgeID);
	}

	/**
	 * 
	 * @param edgeID String
	 * @param flowEdge String
	 */
	public void putOutManEdge(String edgeID, FlowEdge flowEdge) {
		if (nOutManEdges == null)
			nOutManEdges = new java.util.HashMap();
		nOutManEdges.put(edgeID, flowEdge);
	}


  private String nodeCaption = null;
  private boolean startNode = false;
  private boolean finishNode = false;
  private boolean loopNode = false;
  private boolean mergeNode = false;
  /**
   *
   */
  public NodeTaskDataSet() {
  }
  /**
   *
   * @return NodeTaskDataSet
   */
  public static NodeTaskDataSet getNodeTaskDataSet(String FLOW_ID,String NODE_ID,String OBJ_GUID) {
    NodeTaskDataSet dataSet = new NodeTaskDataSet();
    dataSet.FLOW_ID = FLOW_ID;
    dataSet.NODE_ID = NODE_ID;
    dataSet.OBJ_GUID = OBJ_GUID;
    return dataSet;
  }
  /**
   *
   * @return String
   */
  public String getFLOW_ID() {
    return FLOW_ID;
  }
  
  public void setFLOW_ID(String flow_id) {
	  this.FLOW_ID = flow_id;
  }
  
  /**
   *
   */
  private String OBJ_GUID;
  /**
   *
   * @return String
   */
  public String getNODE_ID() {
    return NODE_ID;
  }
  
  public void setNODE_ID(String value) {
	  this.NODE_ID = value;
  }
  
  /**
   *
   * @return String
   */
  public String getOBJ_GUID() {
    return OBJ_GUID;
  }
  
  public void setOBJ_GUID(String value) {
	  this.OBJ_GUID = value;
  }
  
  /**
   *
   * @param nodeCaption String
   */
  public void setNodeCaption(String nodeCaption) {
    this.nodeCaption = nodeCaption;
  }

  public void setStartNode(boolean startNode) {
    this.startNode = startNode;
  }

  public void setFinishNode(boolean finishNode) {
    this.finishNode = finishNode;
  }
  public void setLoopNode(boolean b) {
    this.loopNode = b;
  }
  public void setMergeNode(boolean mergeNode){
	this.mergeNode=mergeNode;
  }
  public void setBIZ_DJBH(String BIZ_DJBH) {
    this.BIZ_DJBH = BIZ_DJBH;
  }

  public void setBIZ_DATE(String BIZ_DATE) {
    this.BIZ_DATE = BIZ_DATE;
  }

  public void setBIZ_UNIT(String BIZ_UNIT) {
    this.BIZ_UNIT = BIZ_UNIT;
  }

  /**
   *
   * @return String
   */
  public String getNodeCaption() {
    return nodeCaption;
  }

  public boolean isStartNode() {
    return startNode;
  }

  public boolean isFinishNode() {
    return finishNode;
  }
  public boolean isLoopNode() {
      return loopNode;
  }
  public boolean isMergeNode(){
	  return mergeNode;
  }
  public String getBIZ_DJBH() {
    return BIZ_DJBH;
  }

  public String getBIZ_DATE() {
    return BIZ_DATE;
  }

  public String getBIZ_UNIT() {
    return BIZ_UNIT;
  }

  /**
   *
   */
  private String FLOW_ID;
  /**
   *
   */
  private String NODE_ID;
  private String BIZ_UNIT = null;
  private String BIZ_DATE = null;
  private String BIZ_DJBH = null;

  /**
   *
   */
  private NodeTaskAddDataSet taskAddDataSet = null;
  private FlowNode flowNode;

  public NodeTaskAddDataSet getTaskAddDataSet() {
    return this.taskAddDataSet;
  }

  public FlowNode getFlowNode() {
    return flowNode;
  }

  /**
   *
   * @param taskAddDataSet NodeTaskAddDataSet
   */
  public void setTaskAddDataSet(NodeTaskAddDataSet taskAddDataSet) {
    this.taskAddDataSet = taskAddDataSet;
  }

  public void setFlowNode(FlowNode flowNode) {
    this.flowNode = flowNode;
  }

  public ESPRowSet lastByToUnit(String tounit){
      int count=getRowCount();
      for(int i=count-1;i>=0;i--){
          ESPRowSet ers =getRowSet(i);
          if(ers.getString(FlowConstants._TASK_TO_UNIT_COL_,"").equals(tounit))return ers;
      }
      return null;
  }
    public ESPRowSet lastStatusTaskToUnit(String tounit,String status){
      int count=getRowCount();
      for (int i = count - 1; i >= 0; i--) {
        ESPRowSet ers = getRowSet(i);
        if (ers.getString(FlowConstants._TASK_TO_UNIT_COL_,"").equals(tounit)&&
            ers.getString(FlowConstants._RESR_IN_CAUSE_COL_, "").equals(status))
          return ers;
      }
      return null;
    }
  public ESPRowSet lastByUnit(String unit){
      int count=getRowCount();
      for(int i=count-1;i>=0;i--){
          ESPRowSet ers =getRowSet(i);
          if(ers.getString(FlowConstants._TASK_UNIT_COL_,"").equals(unit))return ers;
      }
      return null;
  }
  protected String OP_ID;
  public String getOP_ID() {
	  return OP_ID;
  }
  public void setOP_ID(String op_id) {
	  OP_ID = op_id;
  }
  protected String POP_ID;
  public String getPOP_ID() {
	  return POP_ID;
  }
  public void setPOP_ID(String pop_id) {
	  POP_ID = pop_id;
  }

protected String TASK_UNIT;
  public String getTASK_UNIT() {
	  return TASK_UNIT;
  }
  public void setTASK_UNIT(String task_unit) {
	  TASK_UNIT = task_unit;
  }
}
